# -*- coding: utf-8 -*-
"""
线程本地存储TLS(Thread Local Storage)

"""
import sys
import time
from threading import Thread, local, current_thread

import py_global
import logging

logger = logging.getLogger(__name__)


def target0(params):
    thread_local.param = params
    target1()

    pass


def target1():
    param = thread_local.param
    logger.info(f'{current_thread().name}:{param}')

    pass


if __name__ == '__main__':
    thread_local = local()

    thread0 = Thread(target=target0, args=('thread0',), name='thread0', )
    thread1 = Thread(target=target0, args=('thread1',), name='thread1', )

    thread0.start()
    thread1.start()

    thread0.join()
    thread1.join()

    time.sleep(10)

    pass
